package ru.nsu.fit.iconveyor.conveyor.node;

import ru.nsu.fit.iconveyor.conveyor.channel.Channel;

/**
 * Base class for input and output connections of node with channels.
 */
public class NodeConnection <T> {
    /**
     * Name of connection
     */
    private final String name;

    /**
     * Type of connection
     */
    private final Type type;

    /**
     * Channel to connect with
     */
    private String channelId;

    /**
     * Class of data passed by this channel
     */
    private final Class<T> dataClass;

    public NodeConnection(Class<T> dataClass, Type type, String name) {
        if(dataClass == null || type == null || name == null) {
            throw new IllegalArgumentException();
        }
        this.dataClass = dataClass;
        this.type = type;
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public String getChannelId() {
        return channelId;
    }

    public void setChannelId(String channelId) {
        this.channelId = channelId;
    }

    public Type getType() {
        return type;
    }

    public Class<T> getDataClass() {
        return dataClass;
    }

    /**
     * Type of connection with channel (input or output).
     */
    public static enum Type {
        INPUT,
        OUTPUT;
    }
}
